package org.zpmis.api.http;

import org.zpmis.api.business.TestWebService;
import org.zpmis.common.base.BaseController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.zpmis.common.result.PlatformResult;
import org.zpmis.common.result.ResultCode;

import javax.annotation.Resource;

/**
* created with CodeGenerator
* description: 接口 入口类
* @author  Yang
* date: 2021-5-26
* time: 9:06:46
*/
@RestController
@RequestMapping("/test")
@Slf4j
public class TestController extends BaseController{

    @Resource
    private TestWebService testWebService;

    /**
     * hasPermission('/test/common','sys:user:info')  说明当前接口需要有sys:user:info 的权限才能访问
     * hasRole('admin') 说明当前接口需要admin的权限才能访问
     * hasRole('ADMIN') and hasPermission('/admin/adminRoleList','sys:role:info') 拥有ADMIN角色和sys:role:info权限可以访问
     * @param id
     * @return
     */
    //@PreAuthorize("hasPermission('/test/common','sys:user:info')")
    //@PreAuthorize("hasRole('admin')")
    //@PreAuthorize("hasRole('admin') and hasPermission('/admin/adminRoleList','sys:role:info')")
    @GetMapping("common")
    public PlatformResult common(@RequestBody String id){
        try {
            return PlatformResult.success(testWebService.commonService());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return PlatformResult.failure(ResultCode.SUCCESS);
    }


    @GetMapping("common2")
    public PlatformResult common2(@RequestBody String id){
        try {
            return PlatformResult.success(testWebService.commonService());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return PlatformResult.failure(ResultCode.SUCCESS);
    }

}
